﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BaseTools = SharpMap.Tools;
using System.Windows.Input;
using System.Windows;
using SharpMap.Presentation.Views;
using SharpMap.Rendering.Rendering2D;
using BasseActionContext = SharpMap.Tools.ActionContext<SharpMap.Presentation.Views.IMapView2D,
                    SharpMap.Rendering.Rendering2D.Point2D>;
namespace SharpMap.Wpf
{
    public static class MapTools
    {
        /// <summary>
        /// No active tool
        /// </summary>
        public static readonly WpfMapTool None;

        /// <summary>
        /// Pan
        /// </summary>
        public static readonly WpfMapTool Pan;

        /// <summary>
        /// Zoom in
        /// </summary>
        public static readonly WpfMapTool ZoomIn;

        /// <summary>
        /// Zoom out
        /// </summary>
        public static readonly WpfMapTool ZoomOut;

        /// <summary>
        /// Query tool
        /// </summary>
        public static readonly WpfMapTool Query;

        /// <summary>
        /// QueryAdd tool
        /// </summary>
        public static readonly WpfMapTool QueryAdd;

        /// <summary>
        /// QueryRemove tool
        /// </summary>
        public static readonly WpfMapTool QueryRemove;

        /// <summary>
        /// Add feature tool
        /// </summary>
        public static readonly WpfMapTool FeatureAdd;

        /// <summary>
        /// Remove feature tool
        /// </summary>
        public static readonly WpfMapTool FeatureRemove;

        public static RoutedCommand _queryPanCommand = new RoutedCommand ("QueryPan",typeof(MapTools));
        public static RoutedCommand _beginPanCommand = new RoutedCommand("BeginPan", typeof(MapTools));
        public static RoutedCommand _extendPanCommand = new RoutedCommand("ExtendPan", typeof(MapTools));
        public static RoutedCommand _endPanCommand = new RoutedCommand("EndPan", typeof(MapTools));

        static MapTools()
        {
            None = new WpfMapTool();

            WpfMapTool pan = new WpfMapTool();
            
            pan.QueryToolCommandBinding =
                new CommandBinding(_queryPanCommand, (object source, ExecutedRoutedEventArgs e)
                                                        => BaseTools.StandardMapTools2D.Pan.QueryAction(
                                                        (BasseActionContext)e.Parameter));
   
            pan.BeginToolCommandBinding =
                new CommandBinding(_beginPanCommand, (object source, ExecutedRoutedEventArgs e)
                                                        => BaseTools.StandardMapTools2D.Pan.BeginAction(
                                                        (BasseActionContext)e.Parameter));

            pan.ExtendToolCommandBinding =
                new CommandBinding(_extendPanCommand, (object source, ExecutedRoutedEventArgs e)
                                            => BaseTools.StandardMapTools2D.Pan.ExtendAction(
                                            (BasseActionContext)e.Parameter));

            pan.ExtendToolCommandBinding =
                new CommandBinding(_endPanCommand, (object source, ExecutedRoutedEventArgs e)
                                => BaseTools.StandardMapTools2D.Pan.EndAction(
                                (BasseActionContext)e.Parameter));

            Pan = pan;
            //ZoomIn = new MapTool<IMapView2D, Point2D>("ZoomIn", QueryZoomIn, BeginZoomIn, ContinueZoomIn, EndZoomIn);
            //ZoomOut =
            //    new MapTool<IMapView2D, Point2D>("ZoomOut", QueryZoomOut, BeginZoomOut, ContinueZoomOut, EndZoomOut);
            //Query = new MapTool<IMapView2D, Point2D>("Query", QueryQuery, BeginQuery, ContinueQuery, EndQuery);
            //QueryAdd =
            //    new MapTool<IMapView2D, Point2D>("QueryAdd", QueryQueryAdd, BeginQueryAdd, ContinueQueryAdd, EndQueryAdd);
            //QueryRemove =
            //    new MapTool<IMapView2D, Point2D>("QueryRemove", QueryQueryRemove, BeginQueryRemove, ContinueQueryRemove,
            //                                     EndQueryRemove);
            //FeatureAdd =
            //    new MapTool<IMapView2D, Point2D>("FeatureAdd", QueryFeatureAdd, BeginFeatureAdd, ContinueFeatureAdd,
            //                                     EndFeatureAdd);
            //FeatureRemove =
            //    new MapTool<IMapView2D, Point2D>("FeatureRemove", QueryFeatureRemove, BeginFeatureRemove,
            //                                     ContinueFeatureRemove, EndFeatureRemove);
        }

        //static BaseTools.ActionContext<IMapView2D,Point2D>
        //MapContextFromCommand(object source, ExecutedRoutedEventArgs e)
        //{
        //}
    }

  
}
